package nmp.lib;

import nmp.lib.CNmpCmd.*;
import android.content.Context;

public class CNmpDongle extends CNmpDevice {
	
	public static final int NMP_DONGLE_PORT = 13912;
	
	private CNmpCmd m_cmd = null;
	
	public CNmpDongle(Context context) {		
		super(context,NMP_DONGLE_PORT);
		m_cmd = new CNmpJsonCmd();
		
	};
	
	public void GetMessage(String str) {
		NmpCmdBase cmdbase = m_cmd.Parse(str);
		switch(cmdbase.id) {
			case CNmpCmd.NMP_CMD_ID_IDENTIFY:	
				GetIdentifyResponse((NmpCmdIdentifyInfo)cmdbase);
				break;
				
			case CNmpCmd.NMP_CMD_ID_WIFILIST:
				GetWifiListResponse((NmpCmdWifiList)cmdbase);
				break;
	
			case CNmpCmd.NMP_CMD_ID_WIFICONNECT:
				GetWifiConnectResponse((NmpCmdBase)cmdbase);
				break;
		
			case CNmpCmd.NMP_CMD_ID_WIFIDISCONNECT:
				GetWifiDisConnectResponse((NmpCmdBase)cmdbase);
				break;
				
			case CNmpCmd.NMP_CMD_ID_DEVICEINFO:
				GetDeviceInfoResponse((NmpCmdDeviceInfo)cmdbase);
				break;
				
			case CNmpCmd.NMP_CMD_ID_WIFICONFIG:		
				GetWifiConfigResponse((NmpCmdBase)cmdbase);
				break;	
				
			case CNmpCmd.NMP_CMD_ID_WIFIISCONNECTED:	
				GetWifiIsConnectedResponse((NmpCmdIsConnected)cmdbase);
				break;
			default:
				break;
		}
	}

	public void GetIdentifyResponse(NmpCmdIdentifyInfo info) {
		
	}
	
	public void GetWifiListResponse(NmpCmdWifiList info) {
		
	}

	public void GetWifiConnectResponse(NmpCmdBase info) {
		
	}
	
	public void GetWifiDisConnectResponse(NmpCmdBase info) {
		
	}
	
	public void GetDeviceInfoResponse(NmpCmdDeviceInfo info) {
		
	}	

	public void GetWifiConfigResponse(NmpCmdBase info) {
		
	}	
	
	public void GetWifiIsConnectedResponse(NmpCmdIsConnected info) {
		
	}		
	
	public void SendIdentifyCmd(String name,int version) {		
		SendMessage(m_cmd.IdentifyRequestGenerate(name,version));
	}
	
	public void SendGetWifiListCmd() {		
		SendMessage(m_cmd.WifiListRequestGenerate());
	}
	
	public void SendWifiConnectCmd(String ssid, String protect,String password) {		
		SendMessage(m_cmd.WifiConnectRequestGenerate(ssid,protect,password));
	}	
	
	public void SendWifiDisconnectCmd() {		
		SendMessage(m_cmd.WifiDisconnectRequestGenerate());
	}	
	
	public void SendDeviceInfoCmd() {		
		SendMessage(m_cmd.DeviceInfoRequestGenerate());
	}
	
	public void SendWifiConfigCmd(String ssid, String protect,String password) {		
		SendMessage(m_cmd.WifiConfigRequestGenerate(ssid,protect,password));
	}	
	
	public void SendWifiIsConnectedCmd() {		
		SendMessage(m_cmd.WifiIsConnectedRequestGenerate());
	}	
};
